<template>
  <div class="container">
    <div class="header-container">
      <div class="tab-container">
        <div class="tab active" data-tab="efficiency">生活提效</div>
        <div class="tab" data-tab="fitness">运动助手</div>
        <div class="tab" data-tab="health">健康检测</div>
      </div>
    </div>
    <div class="content">
      <HealthIndex v-if="tabName === 'health'"/>
      <SportIndex v-else-if="tabName === 'fitness'"/>
      <LifeIndex v-else-if="tabName === 'efficiency'"/>
    </div>
  </div>
</template>

<script>

import HealthIndex from "@/view/home/health/index.vue";
import SportIndex from "@/view/home/sport/index.vue";
import LifeIndex from "@/view/home/life/index.vue";

export default {
  name: 'HomeIndex',
  components: {
    HealthIndex,
    SportIndex,
    LifeIndex,
  },
  data() {
    return {
      tabName: 'efficiency'
    }
  },
  mounted () {
    const tabs = document.querySelectorAll('.tab');
    console.log(tabs);
    tabs.forEach(tab => {
      tab.addEventListener('click', () => {
        // 移除所有活动状态
        tabs.forEach(t => t.classList.remove('active'));
        // tabContents.forEach(c => c.classList.remove('active'));
        //
        // // 添加当前活动状态
        tab.classList.add('active');
        // const tabId = tab.getAttribute('data-tab');
        // document.getElementById(`${tabId}-content`).classList.add('active');
        this.tabName = tab.getAttribute('data-tab');
        console.log('tabName', this.tabName);
      });
    });
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

:root {
  --primary: #4361ee;
  --secondary: #3f37c9;
  --accent: #4cc9f0;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --dark: #121212;
  --light: #f8f9fa;
  --card-bg: rgba(30, 30, 46, 0.8);
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --transition: all 0.3s ease;
}

body {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  //max-width: 500px;
  width: 100vw;
  background: whitesmoke;
  //border-radius: 25px;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  //border: 1px solid rgba(67, 97, 238, 0.2);
  border: none;
}

.header-container {
  padding: 0 0;
  text-align: center;
  //background: rgba(20, 25, 45, 0.8);
  background: whitesmoke;
  position: relative;
  border-bottom: 1px solid rgba(76, 201, 240, 0.1);
}

.app-title {
  font-size: 1.8rem;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
}

.app-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 15px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  position: absolute;
  top: 15px;
  left: 20px;
  right: 20px;
  font-size: 0.9rem;
  color: var(--accent);
}

.tab-container {
  display: flex;
  justify-content: space-around;
  padding: 0 10px;
  //background: rgba(15, 20, 40, 0.9);
  border-radius: 15px;
  margin: 0 15px;
}

.tab {
  padding: 15px 0;
  flex: 1;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 3px;
  background: var(--accent);
  border-radius: 3px;
}

.content {
  padding: 25px 20px;
  //min-height: 500px;
  height: 100vh;
  background: whitesmoke;
  overflow-y: auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 1.4rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title i {
  color: var(--accent);
  font-size: 1.3rem;
}

/* 生活提效界面样式 */
.efficiency-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 10px;
}

.efficiency-item {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 15px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid rgba(76, 201, 240, 0.1);
}

.efficiency-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  border-color: rgba(76, 201, 240, 0.3);
}

.efficiency-icon {
  font-size: 2.2rem;
  margin-bottom: 15px;
  color: var(--accent);
}

.efficiency-item h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.efficiency-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 运动助手界面样式 */
.fitness-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 10px;
  text-align: center;
  border: 1px solid rgba(76, 201, 240, 0.1);
}

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: var(--accent);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.workout-btn {
  display: block;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 15px;
  padding: 18px;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 25px 0;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
}

.workout-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(67, 97, 238, 0.6);
}

.workout-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.workout-type {
  background: var(--card-bg);
  border-radius: 15px;
  padding: 15px 5px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid rgba(76, 201, 240, 0.1);
}

.workout-type:hover {
  transform: translateY(-3px);
  border-color: rgba(76, 201, 240, 0.3);
}

.workout-type i {
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.workout-type span {
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* 健康检测界面样式 */
.health-metrics {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.metric-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(76, 201, 240, 0.1);
}

.metric-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(76, 201, 240, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 15px;
  font-size: 1.8rem;
  color: var(--accent);
}

.metric-info {
  flex: 1;
}

.metric-title {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 5px;
}

.metric-value {
  color: var(--text-primary);
  font-size: 1.6rem;
  font-weight: 700;
}

.metric-status {
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 5px;
}

.metric-chart {
  width: 100px;
  height: 50px;
  position: relative;
}

.chart-line {
  position: absolute;
  bottom: 0;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

/* 心率动画 */
.heart-rate {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 100px;
  height: 30px;
  overflow: hidden;
}

.heart-line {
  position: absolute;
  bottom: 0;
  width: 200%;
  height: 100%;
  background: repeating-linear-gradient(
      90deg,
      transparent,
      transparent 20px,
      var(--danger) 20px,
      var(--danger) 40px
  );
  animation: moveLine 1.5s linear infinite;
}

@keyframes moveLine {
  0% { transform: translateX(0); }
  100% { transform: translateX(-40px); }
}


.nav-item i {
  font-size: 1.4rem;
  margin-bottom: 5px;
}

/* 响应式设计 */
@media (max-width: 400px) {
  .efficiency-grid {
    grid-template-columns: 1fr;
  }

  .fitness-stats {
    grid-template-columns: 1fr;
  }

  .workout-types {
    grid-template-columns: repeat(2, 1fr);
  }
}

</style>
